import {useEffect, useState} from "react";

export const useMousemove = () => {
    const [x, setX] = useState(0)
    const [y, setY] = useState(0)


    const mousemove = (event) => {
        setX(event.pageX)
        setY(event.pageY)
    }

    useEffect(() => {
        document.addEventListener("mousemove", mousemove)

        return () => {
            document.removeEventListener("mousemove", mousemove)
        }
    }, []);

    return {
        x,
        y
    }
}

export default useMousemove
